<?php
require_once "../config.php";
require_once SESSION_INCLUDE;
require_once DB;
require_once PHOTO;

session_start();

	/*$json = json_decode(stripslashes($_POST['json']));
	echo $json->{"new_gallery_id"};
	*/
	$db = get_session_db($db_config);

	if(!user_is_logged($db))
	{
		header("Location:http://".LOGIN_FILE);
		exit();
	}

	$user = get_session_user();

	$photo_id = null;
	if(!isset($_POST['photo_id']))
	{
	//	header("HTTP/1.1 304 Not Modified");
		exit();
	} else $photo_id = $_POST['photo_id'];

	$photo = Photo::getPhotoFromId($db, $photo_id);

	if(isset($_POST['gallery_id']))
	{
		$photo->set('galery_id', $_POST['gallery_id']);
	}

	if(isset($_POST['photo_description']))
	{
		$photo->setDescription($_POST['photo_description']);
		echo $photo->getDescription();
	}

	if(isset($_POST['photo_title']))
	{
		$photo->setTitle($_POST['photo_title']);
		echo $photo->getTitle();
	}
	$photo->commit();

?>
